﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.Utils;
using DevExpress.XtraEditors;
using WindowsForms.AOnline.Presenter.Dictionary.Department;
using WindowsForms.AOnline.View.Dictionary;
using WindowsForms.AOnline.WindowsForm.BaseUserControls;
using WindowsForms.AOnline.WindowsForm.FormBase.PropertyGrid;

namespace WindowsForms.AOnline.WindowsForm.UserControl.Dictionary
{
    public partial class UserControlDepartmentList : BaseTreeListUserControl, IDepartmentsView  
    {
        private readonly DepartmentsPresenter _departmentsPresenter; 

        public UserControlDepartmentList()
        {
            InitializeComponent();
            _departmentsPresenter = new DepartmentsPresenter(this);
        }

        /// <summary>
        /// Deletes the grid.
        /// </summary>
        protected override string DeleteTree()
        {
            return new DepartmentPresenter(null).Delete(int.Parse(PrimaryKeyValue));
        }

        /// <summary>
        /// Loads the data into grid.
        /// </summary>
        protected override void LoadDataIntoTree(int page)
        {
            TotalPage = _departmentsPresenter.GetPageSize();
            if (page <= TotalPage)
            {
                _departmentsPresenter.Display(page);
            }
        }

        public IList<Model.BusinessObjects.Dictionary.DepartmentModel> Departments
        {
            set
            {
                treeList.DataSource = value;


                //ColumnsCollection.Add(new XtraColumn { ColumnName = "DepartmentCode", ColumnCaption = "Mã phòng ban", ColumnPosition = 1, ColumnVisible = true, ColumnWith = 100 });
                //ColumnsCollection.Add(new XtraColumn { ColumnName = "DepartmentName", ColumnCaption = "Tên phòng ban", ColumnPosition = 2, ColumnVisible = true, ColumnWith = 300 });
                //ColumnsCollection.Add(new XtraColumn { ColumnName = "Description", ColumnCaption = "Diễn giải", ColumnPosition = 3, ColumnVisible = true, ColumnWith = 100 });
                //ColumnsCollection.Add(new XtraColumn { ColumnName = "IsActive", ColumnCaption = "Được sử dụng", ColumnPosition = 4, ColumnVisible = true });
            }
        }
    }
}
